package com.corgi.mybatis.modules.mapper;

import com.corgi.mybatis.annotation.Encrypt;
import com.corgi.mybatis.annotation.EncryptField;
import com.corgi.mybatis.base.DefaultIntegerFieldEncryptStrategy;
import com.corgi.mybatis.base.DefaultStringFieldEncryptStrategy;
import com.corgi.mybatis.base.PageInfo;
import com.corgi.mybatis.modules.domain.People;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @title: PeopleMapper
 * @description:
 * @author: dengmiao
 * @create: 2019-10-18 10:55
 **/
@Repository
public interface PeopleMapper {

    /**
     * 分页
     * @param pageInfo
     * @return
     */
    @Encrypt({
            @EncryptField(field = "firstName", encryptStrategy = DefaultStringFieldEncryptStrategy.class),
            @EncryptField(field = "age", encryptStrategy = DefaultIntegerFieldEncryptStrategy.class)
    })
    List<People> selectListPage(PageInfo pageInfo);

    /**
     * 分页
     * @param pageInfo
     * @return
     */
    @Encrypt({@EncryptField(field = "firstName", encryptStrategy = DefaultStringFieldEncryptStrategy.class)})
    List<People> selectPageList(@Param("pageInfo") PageInfo pageInfo);

    /**
     * list
     * @return
     */
    @Encrypt({@EncryptField(field = "firstName", encryptStrategy = DefaultStringFieldEncryptStrategy.class)})
    List<People> selectList();

    /**
     * toMap
     * @return
     */
    @Encrypt({@EncryptField(field = "first_name", encryptStrategy = DefaultStringFieldEncryptStrategy.class)})
    List<Map> selectListToMap();

    /**
     * 单体对象
     * @param id
     * @return
     */
    @Encrypt({@EncryptField(field = "firstName", encryptStrategy = DefaultStringFieldEncryptStrategy.class)})
    People selectById(Long id);
    /**
     * 对象或map及其集合已实现
     * 未实现 fastjson相关返回
     */
}
